package com.whfc.mach.dao;

import com.whfc.mach.dto.warn.AppMachKVDTO;
import com.whfc.mach.dto.warn.AppWarnMachRecordDTO;
import com.whfc.mach.entity.AppMachWarnRecord;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Repository
public interface AppMachWarnRecordMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(AppMachWarnRecord record);

    int insertSelective(AppMachWarnRecord record);

    AppMachWarnRecord selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(AppMachWarnRecord record);

    int updateByPrimaryKey(AppMachWarnRecord record);

    /**
     * 根据组织机构查找
     *
     * @param deptId
     * @param machIds
     * @param ruleTypes
     * @param state
     * @param startTime
     * @param endTime
     * @return
     */
    List<Integer> selectRuleTypeList(@Param("deptId") Integer deptId,
                                     @Param("machIds") List<Integer> machIds,
                                     @Param("ruleTypes") List<Integer> ruleTypes,
                                     @Param("state") Integer state,
                                     @Param("startTime") Date startTime,
                                     @Param("endTime") Date endTime);

    /**
     * 查找报警记录
     *
     * @param deptId
     * @param state
     * @param ruleType
     * @param startTime
     * @param endTime
     * @return
     */
    List<AppWarnMachRecordDTO> selectByDeptId(@Param("deptId") Integer deptId,
                                              @Param("state") Integer state,
                                              @Param("ruleType") Integer ruleType,
                                              @Param("startTime") Date startTime,
                                              @Param("endTime") Date endTime);

    /**
     * 批量处理报警
     *
     * @param warnIdList
     * @param handleResult
     * @param handleRemark
     * @param userId
     * @param userName
     */
    void batchUpdateState(@Param("warnIdList") List<Integer> warnIdList,
                          @Param("handleResult") String handleResult,
                          @Param("handleRemark") String handleRemark,
                          @Param("userId") Integer userId,
                          @Param("userName") String userName);

    /**
     * 删除
     *
     * @param warnIdList
     */
    void deleteLogic(@Param("warnIdList") List<Integer> warnIdList);

    /**
     * 查询报警数
     *
     * @param deptIds
     * @param startTime
     * @param endTime
     * @return
     */
    Integer countWarnNum(@Param("deptIds") List<Integer> deptIds,
                         @Param("startTime") Date startTime,
                         @Param("endTime") Date endTime);

    /**
     * 查询国网设备报警记录
     *
     * @param machIds
     * @param ruleTypes
     * @param startTime
     * @param endTime
     * @return
     */
    List<AppWarnMachRecordDTO> selectMachWarnList(@Param("machIds") List<Integer> machIds,
                                                  @Param("ruleTypes") List<Integer> ruleTypes,
                                                  @Param("startTime") Date startTime,
                                                  @Param("endTime") Date endTime);

    List<AppMachKVDTO> selectAppMachKVDTO(@Param("deptId") Integer deptId,
                                          @Param("machIds") List<Integer> machIds,
                                          @Param("ruleTypes") List<Integer> ruleTypes,
                                          @Param("state") Integer state,
                                          @Param("startTime") Date startTime,
                                          @Param("endTime") Date endTime);
}